package com.wingsboat.common.filterChain.chain;

import com.wingsboat.common.filterChain.context.WbFilterContext;
import com.wingsboat.common.filterChain.filter.WbFilter;

/**
 * @Author: wangzhong
 * @Date: 2023/11/16 20:40
 * @Description:
 **/

public class DefaultWbFilterChain<T extends WbFilterContext> implements WbFilterChain<T> {
    private WbFilter curFilter;
    private WbFilterChain next;

    public DefaultWbFilterChain(WbFilter curFilter, WbFilterChain chain) {
        this.curFilter = curFilter;
        this.next = chain;
    }

    @Override
    public void handler(T context) {
        curFilter.doFilter(context,next);
    }

    @Override
    public void fireNext(T context,WbFilterChain chain) {
        chain.handler(context);
    }
}
